package com.ltd.zglmvptest.activity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.Toast;

import com.ltd.zglmvptest.R;
import com.ltd.zglmvptest.adapter.AvatarListAdapter;
import com.ltd.zglmvptest.bean.AvatarBean;
import com.ltd.zglmvptest.view.AvatarListView;

import java.util.List;

import static android.R.id.list;

public class MainActivity extends Activity implements AvatarListView {


    private ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        listView = (ListView) findViewById(R.id.listView);
        listView.setAdapter(new AvatarListAdapter(this, list));
    }

    /**
     * 该方法是提示加载数据，实际开发中可能为一个加载动画
     */
    @Override
    public void showProgress()
    {
        Toast.makeText(this, "一大波美女即将到来", Toast.LENGTH_SHORT).show();
    }

    /**
     * 该方法是在获取数据之后显示到适配器
     * @param result 获取到的数据
     */
    @Override
    public void showData(List<AvatarBean> result)
    {
        listView.setAdapter(new AvatarListAdapter(this,result));
    }
}
